﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Imagiality.MeshProcessing
{
    public class SimpleIDGenerator : IDGenerator
    {
        uint lastRootIndex;
        Dictionary<SceneObject, uint> idDictionary;

        public SimpleIDGenerator()
        {
            lastRootIndex = 0;
            idDictionary = new Dictionary<SceneObject, uint>();
        }

        public uint Next(RootSceneObject obj)
        {
            if (obj.GetChilds().Count > 0)
                idDictionary.Add(obj, 0);

            lastRootIndex++;

            return lastRootIndex;
        }

        public uint Next(NodeSceneObject obj)
        {
            if (obj.GetChilds().Count > 0)
                idDictionary.Add(obj, 0);

            idDictionary[obj.Parent] += 1;

            return idDictionary[obj.Parent];
        }
    }
}
